home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / java / awt / Graphics.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  51.5 KB  |  1,132 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)Graphics.java    1.49 98/07/22
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14. package java.awt;
  15.  
  16. import java.io.*;
  17. import java.lang.*;
  18. import java.util.*;
  19. import java.awt.image.ImageObserver;
  20. import java.text.AttributedCharacterIterator;
  21.  
  22. /**
  23.  * The <code>Graphics</code> class is the abstract base class for 
  24.  * all graphics contexts that allow an application to draw onto 
  25.  * components that are realized on various devices, as well as 
  26.  * onto off-screen images.
  27.  * <p>
  28.  * A <code>Graphics</code> object encapsulates state information needed
  29.  * for the basic rendering operations that Java supports.  This
  30.  * state information includes the following properties:
  31.  * <p>
  32.  * <ul>
  33.  * <li>The <code>Component</code> object on which to draw.
  34.  * <li>A translation origin for rendering and clipping coordinates.
  35.  * <li>The current clip.
  36.  * <li>The current color.
  37.  * <li>The current font.
  38.  * <li>The current logical pixel operation function (XOR or Paint).
  39.  * <li>The current XOR alternation color 
  40.  *     (see {@link Graphics#setXORMode}).
  41.  * </ul>
  42.  * <p>
  43.  * Coordinates are infinitely thin and lie between the pixels of the
  44.  * output device.
  45.  * Operations which draw the outline of a figure operate by traversing
  46.  * an infinitely thin path between pixels with a pixel-sized pen that hangs
  47.  * down and to the right of the anchor point on the path.
  48.  * Operations which fill a figure operate by filling the interior
  49.  * of that infinitely thin path.
  50.  * Operations which render horizontal text render the ascending
  51.  * portion of character glyphs entirely above the baseline coordinate.
  52.  * <p>
  53.  * The graphics pen hangs down and to the right from the path it traverses. 
  54.  * This has the following implications:
  55.  * <p><ul>
  56.  * <li>If you draw a figure that covers a given rectangle, that 
  57.  * figure occupies one extra row of pixels on the right and bottom edges 
  58.  * as compared to filling a figure that is bounded by that same rectangle.
  59.  * <li>If you draw a horizontal line along the same <i>y</i> coordinate as
  60.  * the baseline of a line of text, that line is drawn entirely below
  61.  * the text, except for any descenders.
  62.  * </ul><p>
  63.  * All coordinates which appear as arguments to the methods of this
  64.  * <code>Graphics</code> object are considered relative to the 
  65.  * translation origin of this <code>Graphics</code> object prior to 
  66.  * the invocation of the method.
  67.  * All rendering operations modify only pixels which lie within the
  68.  * area bounded by both the current clip of the graphics context
  69.  * and the extents of the component used to create the 
  70.  * <code>Graphics</code> object.
  71.  * All drawing or writing is done in the current color, 
  72.  * using the current paint mode, and in the current font. 
  73.  * 
  74.  * @version     1.49, 07/22/98
  75.  * @author     Sami Shaio
  76.  * @author     Arthur van Hoff
  77.  * @see     java.awt.Component
  78.  * @see     java.awt.Graphics#clipRect(int, int, int, int)
  79.  * @see     java.awt.Graphics#setColor(java.awt.Color)
  80.  * @see     java.awt.Graphics#setPaintMode()
  81.  * @see     java.awt.Graphics#setXORMode(java.awt.Color)
  82.  * @see     java.awt.Graphics#setFont(java.awt.Font)
  83.  * @since       JDK1.0
  84.  */
  85. public abstract class Graphics {
  86.  
  87.     /**
  88.      * Constructs a new <code>Graphics</code> object.  
  89.      * This constructor is the default contructor for a graphics 
  90.      * context. 
  91.      * <p>
  92.      * Since <code>Graphics</code> is an abstract class, applications 
  93.      * cannot call this constructor directly. Graphics contexts are 
  94.      * obtained from other graphics contexts or are created by calling 
  95.      * <code>getGraphics</code> on a component. 
  96.      * @see        java.awt.Graphics#create()
  97.      * @see        java.awt.Component#getGraphics
  98.      */
  99.     protected Graphics() {
  100.     }
  101.  
  102.     /**
  103.      * Creates a new <code>Graphics</code> object that is 
  104.      * a copy of this <code>Graphics</code> object.
  105.      * @return     a new graphics context that is a copy of 
  106.      *                       this graphics context.
  107.      */
  108.     public abstract Graphics create();
  109.  
  110.     /**
  111.      * Creates a new <code>Graphics</code> object based on this 
  112.      * <code>Graphics</code> object, but with a new translation and clip area.
  113.      * The new <code>Graphics</code> object has its origin 
  114.      * translated to the specified point (<i>x</i>, <i>y</i>). 
  115.      * Its clip area is determined by the intersection of the original
  116.      * clip area with the specified rectangle.  The arguments are all
  117.      * interpreted in the coordinate system of the original 
  118.      * <code>Graphics</code> object. The new graphics context is 
  119.      * identical to the original, except in two respects: 
  120.      * <p>
  121.      * <ul>
  122.      * <li>
  123.      * The new graphics context is translated by (<i>x</i>, <i>y</i>).  
  124.      * That is to say, the point (<code>0</code>, <code>0</code>) in the 
  125.      * new graphics context is the same as (<i>x</i>, <i>y</i>) in 
  126.      * the original graphics context. 
  127.      * <li>
  128.      * The new graphics context has an additional clipping rectangle, in 
  129.      * addition to whatever (translated) clipping rectangle it inherited 
  130.      * from the original graphics context. The origin of the new clipping 
  131.      * rectangle is at (<code>0</code>, <code>0</code>), and its size  
  132.      * is specified by the <code>width</code> and <code>height</code> arguments.
  133.      * </ul>
  134.      * <p>
  135.      * @param      x   the <i>x</i> coordinate.
  136.      * @param      y   the <i>y</i> coordinate.
  137.      * @param      width   the width of the clipping rectangle.
  138.      * @param      height   the height of the clipping rectangle.
  139.      * @return     a new graphics context.
  140.      * @see        java.awt.Graphics#translate
  141.      * @see        java.awt.Graphics#clipRect
  142.      */
  143.     public Graphics create(int x, int y, int width, int height) {
  144.     Graphics g = create();
  145.     g.translate(x, y);
  146.     g.clipRect(0, 0, width, height);
  147.     return g;
  148.     }
  149.  
  150.     /**
  151.      * Translates the origin of the graphics context to the point
  152.      * (<i>x</i>, <i>y</i>) in the current coordinate system. 
  153.      * Modifies this graphics context so that its new origin corresponds 
  154.      * to the point (<i>x</i>, <i>y</i>) in this graphics context's 
  155.      * original coordinate system.  All coordinates used in subsequent 
  156.      * rendering operations on this graphics context will be relative 
  157.      * to this new origin.
  158.      * @param  x   the <i>x</i> coordinate.
  159.      * @param  y   the <i>y</i> coordinate.
  160.      */
  161.     public abstract void translate(int x, int y);
  162.  
  163.     /**
  164.      * Gets this graphics context's current color.
  165.      * @return    this graphics context's current color.
  166.      * @see       java.awt.Color
  167.      * @see       java.awt.Graphics#setColor
  168.      */
  169.     public abstract Color getColor();
  170.  
  171.     /**
  172.      * Sets this graphics context's current color to the specified 
  173.      * color. All subsequent graphics operations using this graphics 
  174.      * context use this specified color. 
  175.      * @param     c   the new rendering color.
  176.      * @see       java.awt.Color
  177.      * @see       java.awt.Graphics#getColor
  178.      */
  179.     public abstract void setColor(Color c);
  180.  
  181.     /**
  182.      * Sets the paint mode of this graphics context to overwrite the 
  183.      * destination with this graphics context's current color. 
  184.      * This sets the logical pixel operation function to the paint or
  185.      * overwrite mode.  All subsequent rendering operations will
  186.      * overwrite the destination with the current color. 
  187.      */
  188.     public abstract void setPaintMode();
  189.  
  190.     /**
  191.      * Sets the paint mode of this graphics context to alternate between 
  192.      * this graphics context's current color and the new specified color. 
  193.      * This specifies that logical pixel operations are performed in the 
  194.      * XOR mode, which alternates pixels between the current color and 
  195.      * a specified XOR color. 
  196.      * <p>
  197.      * When drawing operations are performed, pixels which are the 
  198.      * current color are changed to the specified color, and vice versa. 
  199.      * <p>
  200.      * Pixels that are of colors other than those two colors are changed 
  201.      * in an unpredictable but reversible manner; if the same figure is 
  202.      * drawn twice, then all pixels are restored to their original values. 
  203.      * @param     c1 the XOR alternation color
  204.      */
  205.     public abstract void setXORMode(Color c1);
  206.  
  207.     /**
  208.      * Gets the current font.
  209.      * @return    this graphics context's current font.
  210.      * @see       java.awt.Font
  211.      * @see       java.awt.Graphics#setFont
  212.      */
  213.     public abstract Font getFont();
  214.  
  215.     /**
  216.      * Sets this graphics context's font to the specified font. 
  217.      * All subsequent text operations using this graphics context 
  218.      * use this font. 
  219.      * @param  font   the font.
  220.      * @see     java.awt.Graphics#getFont
  221.      * @see     java.awt.Graphics#drawChars(java.lang.String, int, int)
  222.      * @see     java.awt.Graphics#drawString(byte[], int, int, int, int)
  223.      * @see     java.awt.Graphics#drawBytes(char[], int, int, int, int)
  224.     */
  225.     public abstract void setFont(Font font);
  226.  
  227.     /**
  228.      * Gets the font metrics of the current font.
  229.      * @return    the font metrics of this graphics 
  230.      *                    context's current font.
  231.      * @see       java.awt.Graphics#getFont
  232.      * @see       java.awt.FontMetrics
  233.      * @see       java.awt.Graphics#getFontMetrics(Font)
  234.      */
  235.     public FontMetrics getFontMetrics() {
  236.     return getFontMetrics(getFont());
  237.     }
  238.  
  239.     /**
  240.      * Gets the font metrics for the specified font.
  241.      * @return    the font metrics for the specified font.
  242.      * @param     f the specified font
  243.      * @see       java.awt.Graphics#getFont
  244.      * @see       java.awt.FontMetrics
  245.      * @see       java.awt.Graphics#getFontMetrics()
  246.      */
  247.     public abstract FontMetrics getFontMetrics(Font f);
  248.  
  249.  
  250.     /**
  251.      * Returns the bounding rectangle of the current clipping area.
  252.      * The coordinates in the rectangle are relative to the coordinate
  253.      * system origin of this graphics context.
  254.      * @return      the bounding rectangle of the current clipping area.
  255.      * @see         java.awt.Graphics#getClip
  256.      * @see         java.awt.Graphics#clipRect
  257.      * @see         java.awt.Graphics#setClip(int, int, int, int)
  258.      * @see         java.awt.Graphics#setClip(Shape)
  259.      * @since       JDK1.1
  260.      */
  261.     public abstract Rectangle getClipBounds();
  262.  
  263.     /** 
  264.      * Intersects the current clip with the specified rectangle.
  265.      * The resulting clipping area is the intersection of the current
  266.      * clipping area and the specified rectangle.
  267.      * This method can only be used to make the current clip smaller.
  268.      * To set the current clip larger, use any of the setClip methods.
  269.      * Rendering operations have no effect outside of the clipping area.
  270.      * @param x the x coordinate of the rectangle to intersect the clip with
  271.      * @param y the y coordinate of the rectangle to intersect the clip with
  272.      * @param width the width of the rectangle to intersect the clip with
  273.      * @param height the height of the rectangle to intersect the clip with
  274.      * @see #setClip(int, int, int, int)
  275.      * @see #setClip(Shape)
  276.      */
  277.     public abstract void clipRect(int x, int y, int width, int height);
  278.  
  279.     /**
  280.      * Sets the current clip to the rectangle specified by the given
  281.      * coordinates.
  282.      * Rendering operations have no effect outside of the clipping area.
  283.      * @param       x the <i>x</i> coordinate of the new clip rectangle.
  284.      * @param       y the <i>y</i> coordinate of the new clip rectangle.
  285.      * @param       width the width of the new clip rectangle.
  286.      * @param       height the height of the new clip rectangle.
  287.      * @see         java.awt.Graphics#clipRect
  288.      * @see         java.awt.Graphics#setClip(Shape)
  289.      * @since       JDK1.1
  290.      */
  291.     public abstract void setClip(int x, int y, int width, int height);
  292.  
  293.     /**
  294.      * Gets the current clipping area.
  295.      * @return      a <code>Shape</code> object representing the 
  296.      *                      current clipping area.
  297.      * @see         java.awt.Graphics#getClipBounds
  298.      * @see         java.awt.Graphics#clipRect
  299.      * @see         java.awt.Graphics#setClip(int, int, int, int)
  300.      * @see         java.awt.Graphics#setClip(Shape)
  301.      * @since       JDK1.1
  302.      */
  303.     public abstract Shape getClip();
  304.  
  305.     /**
  306.      * Sets the current clipping area to an arbitrary clip shape.
  307.      * Not all objects which implement the <code>Shape</code> 
  308.      * interface can be used to set the clip.  The only 
  309.      * <code>Shape</code> objects which are guaranteed to be 
  310.      * supported are <code>Shape</code> objects which are
  311.      * obtained via the <code>getClip</code> method and via 
  312.      * <code>Rectangle</code> objects.
  313.      * @see         java.awt.Graphics#getClip()
  314.      * @see         java.awt.Graphics#clipRect
  315.      * @see         java.awt.Graphics#setClip(int, int, int, int)
  316.      * @since       JDK1.1
  317.      */
  318.     public abstract void setClip(Shape clip);
  319.  
  320.     /**
  321.      * Copies an area of the component by a distance specified by 
  322.      * <code>dx</code> and <code>dy</code>. From the point specified
  323.      * by <code>x</code> and <code>y</code>, this method
  324.      * copies downwards and to the right.  To copy an area of the 
  325.      * component to the left or upwards, specify a negative value for 
  326.      * <code>dx</code> or <code>dy</code>.
  327.      * If a portion of the source rectangle lies outside the bounds 
  328.      * of the component, or is obscured by another window or component, 
  329.      * <code>copyArea</code> will be unable to copy the associated
  330.      * pixels. The area that is omitted can be refreshed by calling 
  331.      * the component's <code>paint</code> method.
  332.      * @param       x the <i>x</i> coordinate of the source rectangle.
  333.      * @param       y the <i>y</i> coordinate of the source rectangle.
  334.      * @param       width the width of the source rectangle.
  335.      * @param       height the height of the source rectangle.
  336.      * @param       dx the horizontal distance to copy the pixels.
  337.      * @param       dy the vertical distance to copy the pixels.
  338.      */
  339.     public abstract void copyArea(int x, int y, int width, int height,
  340.                   int dx, int dy);
  341.  
  342.     /** 
  343.      * Draws a line, using the current color, between the points 
  344.      * <code>(x1, y1)</code> and <code>(x2, y2)</code> 
  345.      * in this graphics context's coordinate system. 
  346.      * @param   x1  the first point's <i>x</i> coordinate.
  347.      * @param   y1  the first point's <i>y</i> coordinate.
  348.      * @param   x2  the second point's <i>x</i> coordinate.
  349.      * @param   y2  the second point's <i>y</i> coordinate.
  350.      */
  351.     public abstract void drawLine(int x1, int y1, int x2, int y2);
  352.  
  353.     /** 
  354.      * Fills the specified rectangle. 
  355.      * The left and right edges of the rectangle are at 
  356.      * <code>x</code> and <code>x + width - 1</code>. 
  357.      * The top and bottom edges are at 
  358.      * <code>y</code> and <code>y + height - 1</code>. 
  359.      * The resulting rectangle covers an area 
  360.      * <code>width</code> pixels wide by 
  361.      * <code>height</code> pixels tall.
  362.      * The rectangle is filled using the graphics context's current color. 
  363.      * @param         x   the <i>x</i> coordinate 
  364.      *                         of the rectangle to be filled.
  365.      * @param         y   the <i>y</i> coordinate 
  366.      *                         of the rectangle to be filled.
  367.      * @param         width   the width of the rectangle to be filled.
  368.      * @param         height   the height of the rectangle to be filled.
  369.      * @see           java.awt.Graphics#clearRect
  370.      * @see           java.awt.Graphics#drawRect
  371.      */
  372.     public abstract void fillRect(int x, int y, int width, int height);
  373.  
  374.     /** 
  375.      * Draws the outline of the specified rectangle. 
  376.      * The left and right edges of the rectangle are at 
  377.      * <code>x</code> and <code>x + width</code>. 
  378.      * The top and bottom edges are at 
  379.      * <code>y</code> and <code>y + height</code>. 
  380.      * The rectangle is drawn using the graphics context's current color.
  381.      * @param         x   the <i>x</i> coordinate 
  382.      *                         of the rectangle to be drawn.
  383.      * @param         y   the <i>y</i> coordinate 
  384.      *                         of the rectangle to be drawn.
  385.      * @param         width   the width of the rectangle to be drawn.
  386.      * @param         height   the height of the rectangle to be drawn.
  387.      * @see          java.awt.Graphics#fillRect
  388.      * @see          java.awt.Graphics#clearRect
  389.      */
  390.     public void drawRect(int x, int y, int width, int height) {
  391.     if ((width < 0) || (height < 0)) {
  392.         return;
  393.     }
  394.  
  395.     if (height == 0 || width == 0) {
  396.         drawLine(x, y, x + width, y + height);
  397.     } else {
  398.         drawLine(x, y, x + width - 1, y);
  399.         drawLine(x + width, y, x + width, y + height - 1);
  400.         drawLine(x + width, y + height, x + 1, y + height);
  401.         drawLine(x, y + height, x, y + 1);
  402.     }
  403.     }
  404.     
  405.     /** 
  406.      * Clears the specified rectangle by filling it with the background
  407.      * color of the current drawing surface. This operation does not 
  408.      * use the current paint mode. 
  409.      * <p>
  410.      * Beginning with Java 1.1, the background color 
  411.      * of offscreen images may be system dependent. Applications should 
  412.      * use <code>setColor</code> followed by <code>fillRect</code> to 
  413.      * ensure that an offscreen image is cleared to a specific color. 
  414.      * @param       x the <i>x</i> coordinate of the rectangle to clear.
  415.      * @param       y the <i>y</i> coordinate of the rectangle to clear.
  416.      * @param       width the width of the rectangle to clear.
  417.      * @param       height the height of the rectangle to clear.
  418.      * @see         java.awt.Graphics#fillRect(int, int, int, int)
  419.      * @see         java.awt.Graphics#drawRect
  420.      * @see         java.awt.Graphics#setColor(java.awt.Color)
  421.      * @see         java.awt.Graphics#setPaintMode
  422.      * @see         java.awt.Graphics#setXORMode(java.awt.Color)
  423.      */
  424.     public abstract void clearRect(int x, int y, int width, int height);
  425.  
  426.     /** 
  427.      * Draws an outlined round-cornered rectangle using this graphics 
  428.      * context's current color. The left and right edges of the rectangle 
  429.      * are at <code>x</code> and <code>x + width</code>, 
  430.      * respectively. The top and bottom edges of the rectangle are at 
  431.      * <code>y</code> and <code>y + height</code>. 
  432.      * @param      x the <i>x</i> coordinate of the rectangle to be drawn.
  433.      * @param      y the <i>y</i> coordinate of the rectangle to be drawn.
  434.      * @param      width the width of the rectangle to be drawn.
  435.      * @param      height the height of the rectangle to be drawn.
  436.      * @param      arcWidth the horizontal diameter of the arc 
  437.      *                    at the four corners.
  438.      * @param      arcHeight the vertical diameter of the arc 
  439.      *                    at the four corners.
  440.      * @see        java.awt.Graphics#fillRoundRect
  441.      */
  442.     public abstract void drawRoundRect(int x, int y, int width, int height,
  443.                        int arcWidth, int arcHeight);
  444.  
  445.     /** 
  446.      * Fills the specified rounded corner rectangle with the current color.
  447.      * The left and right edges of the rectangle 
  448.      * are at <code>x</code> and <code>x + width - 1</code>, 
  449.      * respectively. The top and bottom edges of the rectangle are at 
  450.      * <code>y</code> and <code>y + height - 1</code>. 
  451.      * @param       x the <i>x</i> coordinate of the rectangle to be filled.
  452.      * @param       y the <i>y</i> coordinate of the rectangle to be filled.
  453.      * @param       width the width of the rectangle to be filled.
  454.      * @param       height the height of the rectangle to be filled.
  455.      * @param       arcWidth the horizontal diameter 
  456.      *                     of the arc at the four corners.
  457.      * @param       arcHeight the vertical diameter 
  458.      *                     of the arc at the four corners.
  459.      * @see         java.awt.Graphics#drawRoundRect
  460.      */
  461.     public abstract void fillRoundRect(int x, int y, int width, int height,
  462.                        int arcWidth, int arcHeight);
  463.  
  464.     /**
  465.      * Draws a 3-D highlighted outline of the specified rectangle.
  466.      * The edges of the rectangle are highlighted so that they
  467.      * appear to be beveled and lit from the upper left corner.
  468.      * <p>
  469.      * The colors used for the highlighting effect are determined 
  470.      * based on the current color.
  471.      * The resulting rectangle covers an area that is 
  472.      * <code>width + 1</code> pixels wide
  473.      * by <code>height + 1</code> pixels tall.
  474.      * @param       x the <i>x</i> coordinate of the rectangle to be drawn.
  475.      * @param       y the <i>y</i> coordinate of the rectangle to be drawn.
  476.      * @param       width the width of the rectangle to be drawn.
  477.      * @param       height the height of the rectangle to be drawn.
  478.      * @param       raised a boolean that determines whether the rectangle
  479.      *                      appears to be raised above the surface 
  480.      *                      or sunk into the surface.
  481.      * @see         java.awt.Graphics#fill3DRect
  482.      */
  483.     public void draw3DRect(int x, int y, int width, int height,
  484.                boolean raised) {
  485.     Color c = getColor();
  486.     Color brighter = c.brighter();
  487.     Color darker = c.darker();
  488.  
  489.     setColor(raised ? brighter : darker);
  490.     drawLine(x, y, x, y + height);
  491.     drawLine(x + 1, y, x + width - 1, y);
  492.     setColor(raised ? darker : brighter);
  493.     drawLine(x + 1, y + height, x + width, y + height);
  494.     drawLine(x + width, y, x + width, y + height - 1);
  495.     setColor(c);
  496.     }    
  497.  
  498.     /**
  499.      * Paints a 3-D highlighted rectangle filled with the current color.
  500.      * The edges of the rectangle will be highlighted so that it appears
  501.      * as if the edges were beveled and lit from the upper left corner.
  502.      * The colors used for the highlighting effect will be determined from
  503.      * the current color.
  504.      * @param       x the <i>x</i> coordinate of the rectangle to be filled.
  505.      * @param       y the <i>y</i> coordinate of the rectangle to be filled.
  506.      * @param       width the width of the rectangle to be filled.
  507.      * @param       height the height of the rectangle to be filled.
  508.      * @param       raised a boolean value that determines whether the 
  509.      *                      rectangle appears to be raised above the surface 
  510.      *                      or etched into the surface.
  511.      * @see         java.awt.Graphics#draw3DRect
  512.      */
  513.     public void fill3DRect(int x, int y, int width, int height,
  514.                boolean raised) {
  515.     Color c = getColor();
  516.     Color brighter = c.brighter();
  517.     Color darker = c.darker();
  518.  
  519.     if (!raised) {
  520.         setColor(darker);
  521.     }
  522.     fillRect(x+1, y+1, width-2, height-2);
  523.     setColor(raised ? brighter : darker);
  524.     drawLine(x, y, x, y + height - 1);
  525.     drawLine(x + 1, y, x + width - 2, y);
  526.     setColor(raised ? darker : brighter);
  527.     drawLine(x + 1, y + height - 1, x + width - 1, y + height - 1);
  528.     drawLine(x + width - 1, y, x + width - 1, y + height - 2);
  529.     setColor(c);
  530.     }    
  531.  
  532.     /** 
  533.      * Draws the outline of an oval.
  534.      * The result is a circle or ellipse that fits within the 
  535.      * rectangle specified by the <code>x</code>, <code>y</code>, 
  536.      * <code>width</code>, and <code>height</code> arguments. 
  537.      * <p> 
  538.      * The oval covers an area that is 
  539.      * <code>width + 1</code> pixels wide 
  540.      * and <code>height + 1</code> pixels tall. 
  541.      * @param       x the <i>x</i> coordinate of the upper left 
  542.      *                     corner of the oval to be drawn.
  543.      * @param       y the <i>y</i> coordinate of the upper left 
  544.      *                     corner of the oval to be drawn.
  545.      * @param       width the width of the oval to be drawn.
  546.      * @param       height the height of the oval to be drawn.
  547.      * @see         java.awt.Graphics#fillOval
  548.      */
  549.     public abstract void drawOval(int x, int y, int width, int height);
  550.  
  551.     /** 
  552.      * Fills an oval bounded by the specified rectangle with the
  553.      * current color.
  554.      * @param       x the <i>x</i> coordinate of the upper left corner 
  555.      *                     of the oval to be filled.
  556.      * @param       y the <i>y</i> coordinate of the upper left corner 
  557.      *                     of the oval to be filled.
  558.      * @param       width the width of the oval to be filled.
  559.      * @param       height the height of the oval to be filled.
  560.      * @see         java.awt.Graphics#drawOval
  561.      */
  562.     public abstract void fillOval(int x, int y, int width, int height);
  563.  
  564.     /**
  565.      * Draws the outline of a circular or elliptical arc 
  566.      * covering the specified rectangle.
  567.      * <p>
  568.      * The resulting arc begins at <code>startAngle</code> and extends  
  569.      * for <code>arcAngle</code> degrees, using the current color.
  570.      * Angles are interpreted such that 0 degrees 
  571.      * is at the 3 o'clock position. 
  572.      * A positive value indicates a counter-clockwise rotation
  573.      * while a negative value indicates a clockwise rotation.
  574.      * <p>
  575.      * The center of the arc is the center of the rectangle whose origin 
  576.      * is (<i>x</i>, <i>y</i>) and whose size is specified by the 
  577.      * <code>width</code> and <code>height</code> arguments. 
  578.      * <p>
  579.      * The resulting arc covers an area 
  580.      * <code>width + 1</code> pixels wide
  581.      * by <code>height + 1</code> pixels tall.
  582.      * <p>
  583.      * The angles are specified relative to the non-square extents of
  584.      * the bounding rectangle such that 45 degrees always falls on the
  585.      * line from the center of the ellipse to the upper right corner of
  586.      * the bounding rectangle. As a result, if the bounding rectangle is
  587.      * noticeably longer in one axis than the other, the angles to the
  588.      * start and end of the arc segment will be skewed farther along the
  589.      * longer axis of the bounds.
  590.      * @param        x the <i>x</i> coordinate of the 
  591.      *                    upper-left corner of the arc to be drawn.
  592.      * @param        y the <i>y</i>  coordinate of the 
  593.      *                    upper-left corner of the arc to be drawn.
  594.      * @param        width the width of the arc to be drawn.
  595.      * @param        height the height of the arc to be drawn.
  596.      * @param        startAngle the beginning angle.
  597.      * @param        arcAngle the angular extent of the arc, 
  598.      *                    relative to the start angle.
  599.      * @see         java.awt.Graphics#fillArc
  600.      */
  601.     public abstract void drawArc(int x, int y, int width, int height,
  602.                  int startAngle, int arcAngle);
  603.  
  604.     /** 
  605.      * Fills a circular or elliptical arc covering the specified rectangle.
  606.      * <p>
  607.      * The resulting arc begins at <code>startAngle</code> and extends  
  608.      * for <code>arcAngle</code> degrees.
  609.      * Angles are interpreted such that 0 degrees 
  610.      * is at the 3 o'clock position. 
  611.      * A positive value indicates a counter-clockwise rotation
  612.      * while a negative value indicates a clockwise rotation.
  613.      * <p>
  614.      * The center of the arc is the center of the rectangle whose origin 
  615.      * is (<i>x</i>, <i>y</i>) and whose size is specified by the 
  616.      * <code>width</code> and <code>height</code> arguments. 
  617.      * <p>
  618.      * The resulting arc covers an area 
  619.      * <code>width + 1</code> pixels wide
  620.      * by <code>height + 1</code> pixels tall.
  621.      * <p>
  622.      * The angles are specified relative to the non-square extents of
  623.      * the bounding rectangle such that 45 degrees always falls on the
  624.      * line from the center of the ellipse to the upper right corner of
  625.      * the bounding rectangle. As a result, if the bounding rectangle is
  626.      * noticeably longer in one axis than the other, the angles to the
  627.      * start and end of the arc segment will be skewed farther along the
  628.      * longer axis of the bounds.
  629.      * @param        x the <i>x</i> coordinate of the 
  630.      *                    upper-left corner of the arc to be filled.
  631.      * @param        y the <i>y</i>  coordinate of the 
  632.      *                    upper-left corner of the arc to be filled.
  633.      * @param        width the width of the arc to be filled.
  634.      * @param        height the height of the arc to be filled.
  635.      * @param        startAngle the beginning angle.
  636.      * @param        arcAngle the angular extent of the arc, 
  637.      *                    relative to the start angle.
  638.      * @see         java.awt.Graphics#drawArc
  639.      */
  640.     public abstract void fillArc(int x, int y, int width, int height,
  641.                  int startAngle, int arcAngle);
  642.  
  643.     /** 
  644.      * Draws a sequence of connected lines defined by 
  645.      * arrays of <i>x</i> and <i>y</i> coordinates. 
  646.      * Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.
  647.      * The figure is not closed if the first point 
  648.      * differs from the last point.
  649.      * @param       xPoints an array of <i>x</i> points
  650.      * @param       yPoints an array of <i>y</i> points
  651.      * @param       nPoints the total number of points
  652.      * @see         java.awt.Graphics#drawPolygon(int[], int[], int)
  653.      * @since       JDK1.1
  654.      */
  655.     public abstract void drawPolyline(int xPoints[], int yPoints[],
  656.                       int nPoints);
  657.  
  658.     /** 
  659.      * Draws a closed polygon defined by 
  660.      * arrays of <i>x</i> and <i>y</i> coordinates. 
  661.      * Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.
  662.      * <p>
  663.      * This method draws the polygon defined by <code>nPoint</code> line 
  664.      * segments, where the first <code>nPoint - 1</code> 
  665.      * line segments are line segments from 
  666.      * <code>(xPoints[i - 1], yPoints[i - 1])</code> 
  667.      * to <code>(xPoints[i], yPoints[i])</code>, for 
  668.      * 1 ≤ <i>i</i> ≤ <code>nPoints</code>.  
  669.      * The figure is automatically closed by drawing a line connecting
  670.      * the final point to the first point, if those points are different.
  671.      * @param        xPoints   a an array of <code>x</code> coordinates.
  672.      * @param        yPoints   a an array of <code>y</code> coordinates.
  673.      * @param        nPoints   a the total number of points.
  674.      * @see          java.awt.Graphics#fillPolygon
  675.      * @see          java.awt.Graphics#drawPolyline
  676.      */
  677.     public abstract void drawPolygon(int xPoints[], int yPoints[],
  678.                      int nPoints);
  679.  
  680.     /** 
  681.      * Draws the outline of a polygon defined by the specified 
  682.      * <code>Polygon</code> object. 
  683.      * @param        p the polygon to draw.
  684.      * @see          java.awt.Graphics#fillPolygon
  685.      * @see          java.awt.Graphics#drawPolyline
  686.      */
  687.     public void drawPolygon(Polygon p) {
  688.     drawPolygon(p.xpoints, p.ypoints, p.npoints);
  689.     }
  690.  
  691.     /** 
  692.      * Fills a closed polygon defined by 
  693.      * arrays of <i>x</i> and <i>y</i> coordinates. 
  694.      * <p>
  695.      * This method draws the polygon defined by <code>nPoint</code> line 
  696.      * segments, where the first <code>nPoint - 1</code> 
  697.      * line segments are line segments from 
  698.      * <code>(xPoints[i - 1], yPoints[i - 1])</code> 
  699.      * to <code>(xPoints[i], yPoints[i])</code>, for 
  700.      * 1 ≤ <i>i</i> ≤ <code>nPoints</code>.  
  701.      * The figure is automatically closed by drawing a line connecting
  702.      * the final point to the first point, if those points are different.
  703.      * <p>
  704.      * The area inside the polygon is defined using an 
  705.      * even-odd fill rule, also known as the alternating rule.
  706.      * @param        xPoints   a an array of <code>x</code> coordinates.
  707.      * @param        yPoints   a an array of <code>y</code> coordinates.
  708.      * @param        nPoints   a the total number of points.
  709.      * @see          java.awt.Graphics#drawPolygon(int[], int[], int)
  710.      */
  711.     public abstract void fillPolygon(int xPoints[], int yPoints[],
  712.                      int nPoints);
  713.  
  714.     /** 
  715.      * Fills the polygon defined by the specified Polygon object with
  716.      * the graphics context's current color. 
  717.      * <p>
  718.      * The area inside the polygon is defined using an 
  719.      * even-odd fill rule, also known as the alternating rule.
  720.      * @param        p the polygon to fill.
  721.      * @see          java.awt.Graphics#drawPolygon(int[], int[], int)
  722.      */
  723.     public void fillPolygon(Polygon p) {
  724.     fillPolygon(p.xpoints, p.ypoints, p.npoints);
  725.     }
  726.  
  727.     /** 
  728.      * Draws the text given by the specified string, using this 
  729.      * graphics context's current font and color. The baseline of the 
  730.      * first character is at position (<i>x</i>, <i>y</i>) in this 
  731.      * graphics context's coordinate system. 
  732.      * @param       str      the string to be drawn.
  733.      * @param       x        the <i>x</i> coordinate.
  734.      * @param       y        the <i>y</i> coordinate.
  735.      * @see         java.awt.Graphics#drawBytes
  736.      * @see         java.awt.Graphics#drawChars
  737.      */
  738.     public abstract void drawString(String str, int x, int y);
  739.  
  740.     /** 
  741.      * Draws the text given by the specified iterator, using this 
  742.      * graphics context's current color. The iterator has to specify a font
  743.      * for each character. The baseline of the 
  744.      * first character is at position (<i>x</i>, <i>y</i>) in this 
  745.      * graphics context's coordinate system. 
  746.      * @param       iterator the iterator whose text is to be drawn
  747.      * @param       x        the <i>x</i> coordinate.
  748.      * @param       y        the <i>y</i> coordinate.
  749.      * @see         java.awt.Graphics#drawBytes
  750.      * @see         java.awt.Graphics#drawChars
  751.      */
  752.    public abstract void drawString(AttributedCharacterIterator iterator,
  753.                                     int x, int y);
  754.  
  755.     /** 
  756.      * Draws the text given by the specified character array, using this 
  757.      * graphics context's current font and color. The baseline of the 
  758.      * first character is at position (<i>x</i>, <i>y</i>) in this 
  759.      * graphics context's coordinate system. 
  760.      * @param data the array of characters to be drawn
  761.      * @param offset the start offset in the data
  762.      * @param length the number of characters to be drawn
  763.      * @param x the <i>x</i> coordinate of the baseline of the text
  764.      * @param y the <i>y</i> coordinate of the baseline of the text
  765.      * @see         java.awt.Graphics#drawBytes
  766.      * @see         java.awt.Graphics#drawString
  767.      */
  768.     public void drawChars(char data[], int offset, int length, int x, int y) {
  769.     drawString(new String(data, offset, length), x, y);
  770.     }
  771.  
  772.     /** 
  773.      * Draws the text given by the specified byte array, using this 
  774.      * graphics context's current font and color. The baseline of the 
  775.      * first character is at position (<i>x</i>, <i>y</i>) in this 
  776.      * graphics context's coordinate system.
  777.      * @param data the data to be drawn
  778.      * @param offset the start offset in the data
  779.      * @param length the number of bytes that are drawn
  780.      * @param x the <i>x</i> coordinate of the baseline of the text
  781.      * @param y the <i>y</i> coordinate of the baseline of the text
  782.      * @see         java.awt.Graphics#drawChars
  783.      * @see         java.awt.Graphics#drawString
  784.      */
  785.     public void drawBytes(byte data[], int offset, int length, int x, int y) {
  786.     drawString(new String(data, 0, offset, length), x, y);
  787.     }
  788.  
  789.     /** 
  790.      * Draws as much of the specified image as is currently available.
  791.      * The image is drawn with its top-left corner at 
  792.      * (<i>x</i>, <i>y</i>) in this graphics context's coordinate 
  793.      * space. Transparent pixels in the image do not affect whatever 
  794.      * pixels are already there. 
  795.      * <p>
  796.      * This method returns immediately in all cases, even if the
  797.      * complete image has not yet been loaded, and it has not been dithered 
  798.      * and converted for the current output device.
  799.      * <p>
  800.      * If the image has not yet been completely loaded, then
  801.      * <code>drawImage</code> returns <code>false</code>. As more of
  802.      * the image becomes available, the process that draws the image notifies 
  803.      * the specified image observer.
  804.      * @param    img the specified image to be drawn.
  805.      * @param    x   the <i>x</i> coordinate.
  806.      * @param    y   the <i>y</i> coordinate.
  807.      * @param    observer    object to be notified as more of 
  808.      *                          the image is converted.
  809.      * @see      java.awt.Image
  810.      * @see      java.awt.image.ImageObserver
  811.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  812.      */
  813.     public abstract boolean drawImage(Image img, int x, int y, 
  814.                       ImageObserver observer);
  815.  
  816.     /**
  817.      * Draws as much of the specified image as has already been scaled
  818.      * to fit inside the specified rectangle.
  819.      * <p>
  820.      * The image is drawn inside the specified rectangle of this 
  821.      * graphics context's coordinate space, and is scaled if 
  822.      * necessary. Transparent pixels do not affect whatever pixels
  823.      * are already there. 
  824.      * <p>
  825.      * This method returns immediately in all cases, even if the
  826.      * entire image has not yet been scaled, dithered, and converted
  827.      * for the current output device.
  828.      * If the current output representation is not yet complete, then
  829.      * <code>drawImage</code> returns <code>false</code>. As more of
  830.      * the image becomes available, the process that draws the image notifies 
  831.      * the image observer by calling its <code>imageUpdate</code> method.
  832.      * <p>
  833.      * A scaled version of an image will not necessarily be
  834.      * available immediately just because an unscaled version of the
  835.      * image has been constructed for this output device.  Each size of
  836.      * the image may be cached separately and generated from the original
  837.      * data in a separate image production sequence.
  838.      * @param    img    the specified image to be drawn.
  839.      * @param    x      the <i>x</i> coordinate.
  840.      * @param    y      the <i>y</i> coordinate.
  841.      * @param    width  the width of the rectangle.
  842.      * @param    height the height of the rectangle.
  843.      * @param    observer    object to be notified as more of 
  844.      *                          the image is converted.
  845.      * @see      java.awt.Image
  846.      * @see      java.awt.image.ImageObserver
  847.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  848.      */
  849.     public abstract boolean drawImage(Image img, int x, int y,
  850.                       int width, int height, 
  851.                       ImageObserver observer);
  852.     
  853.     /** 
  854.      * Draws as much of the specified image as is currently available.
  855.      * The image is drawn with its top-left corner at 
  856.      * (<i>x</i>, <i>y</i>) in this graphics context's coordinate 
  857.      * space.  Transparent pixels are drawn in the specified
  858.      * background color.
  859.      * <p> 
  860.      * This operation is equivalent to filling a rectangle of the
  861.      * width and height of the specified image with the given color and then
  862.      * drawing the image on top of it, but possibly more efficient.
  863.      * <p>
  864.      * This method returns immediately in all cases, even if the
  865.      * complete image has not yet been loaded, and it has not been dithered 
  866.      * and converted for the current output device.
  867.      * <p>
  868.      * If the image has not yet been completely loaded, then
  869.      * <code>drawImage</code> returns <code>false</code>. As more of
  870.      * the image becomes available, the process that draws the image notifies 
  871.      * the specified image observer.
  872.      * @param    img    the specified image to be drawn.
  873.      * @param    x      the <i>x</i> coordinate.
  874.      * @param    y      the <i>y</i> coordinate.
  875.      * @param    bgcolor the background color to paint under the
  876.      *                         non-opaque portions of the image.
  877.      * @param    observer    object to be notified as more of 
  878.      *                          the image is converted.
  879.      * @see      java.awt.Image
  880.      * @see      java.awt.image.ImageObserver
  881.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  882.      */
  883.     public abstract boolean drawImage(Image img, int x, int y, 
  884.                       Color bgcolor,
  885.                       ImageObserver observer);
  886.  
  887.     /**
  888.      * Draws as much of the specified image as has already been scaled
  889.      * to fit inside the specified rectangle.
  890.      * <p>
  891.      * The image is drawn inside the specified rectangle of this 
  892.      * graphics context's coordinate space, and is scaled if 
  893.      * necessary. Transparent pixels are drawn in the specified
  894.      * background color. 
  895.      * This operation is equivalent to filling a rectangle of the
  896.      * width and height of the specified image with the given color and then
  897.      * drawing the image on top of it, but possibly more efficient.
  898.      * <p>
  899.      * This method returns immediately in all cases, even if the
  900.      * entire image has not yet been scaled, dithered, and converted
  901.      * for the current output device.
  902.      * If the current output representation is not yet complete then
  903.      * <code>drawImage</code> returns <code>false</code>. As more of
  904.      * the image becomes available, the process that draws the image notifies 
  905.      * the specified image observer.
  906.      * <p>
  907.      * A scaled version of an image will not necessarily be
  908.      * available immediately just because an unscaled version of the
  909.      * image has been constructed for this output device.  Each size of
  910.      * the image may be cached separately and generated from the original
  911.      * data in a separate image production sequence.
  912.      * @param    img       the specified image to be drawn.
  913.      * @param    x         the <i>x</i> coordinate.
  914.      * @param    y         the <i>y</i> coordinate.
  915.      * @param    width     the width of the rectangle.
  916.      * @param    height    the height of the rectangle.
  917.      * @param    bgcolor   the background color to paint under the
  918.      *                         non-opaque portions of the image.
  919.      * @param    observer    object to be notified as more of 
  920.      *                          the image is converted.
  921.      * @see      java.awt.Image
  922.      * @see      java.awt.image.ImageObserver
  923.      * @see      java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  924.      */
  925.     public abstract boolean drawImage(Image img, int x, int y,
  926.                       int width, int height, 
  927.                       Color bgcolor,
  928.                       ImageObserver observer);
  929.     
  930.     /**
  931.      * Draws as much of the specified area of the specified image as is
  932.      * currently available, scaling it on the fly to fit inside the
  933.      * specified area of the destination drawable surface. Transparent pixels 
  934.      * do not affect whatever pixels are already there.
  935.      * <p>
  936.      * This method returns immediately in all cases, even if the
  937.      * image area to be drawn has not yet been scaled, dithered, and converted
  938.      * for the current output device.
  939.      * If the current output representation is not yet complete then
  940.      * <code>drawImage</code> returns <code>false</code>. As more of
  941.      * the image becomes available, the process that draws the image notifies 
  942.      * the specified image observer.
  943.      * <p>
  944.      * This method always uses the unscaled version of the image
  945.      * to render the scaled rectangle and performs the required
  946.      * scaling on the fly. It does not use a cached, scaled version
  947.      * of the image for this operation. Scaling of the image from source
  948.      * to destination is performed such that the first coordinate
  949.      * of the source rectangle is mapped to the first coordinate of
  950.      * the destination rectangle, and the second source coordinate is
  951.      * mapped to the second destination coordinate. The subimage is
  952.      * scaled and flipped as needed to preserve those mappings.
  953.      * @param       img the specified image to be drawn
  954.      * @param       dx1 the <i>x</i> coordinate of the first corner of the
  955.      *                    destination rectangle.
  956.      * @param       dy1 the <i>y</i> coordinate of the first corner of the
  957.      *                    destination rectangle.
  958.      * @param       dx2 the <i>x</i> coordinate of the second corner of the
  959.      *                    destination rectangle.
  960.      * @param       dy2 the <i>y</i> coordinate of the second corner of the
  961.      *                    destination rectangle.
  962.      * @param       sx1 the <i>x</i> coordinate of the first corner of the
  963.      *                    source rectangle.
  964.      * @param       sy1 the <i>y</i> coordinate of the first corner of the
  965.      *                    source rectangle.
  966.      * @param       sx2 the <i>x</i> coordinate of the second corner of the
  967.      *                    source rectangle.
  968.      * @param       sy2 the <i>y</i> coordinate of the second corner of the
  969.      *                    source rectangle.
  970.      * @param       observer object to be notified as more of the image is
  971.      *                    scaled and converted.
  972.      * @see         java.awt.Image
  973.      * @see         java.awt.image.ImageObserver
  974.      * @see         java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  975.      * @since       JDK1.1
  976.      */
  977.     public abstract boolean drawImage(Image img,
  978.                       int dx1, int dy1, int dx2, int dy2,
  979.                       int sx1, int sy1, int sx2, int sy2,
  980.                       ImageObserver observer);
  981.  
  982.     /**
  983.      * Draws as much of the specified area of the specified image as is
  984.      * currently available, scaling it on the fly to fit inside the
  985.      * specified area of the destination drawable surface. 
  986.      * <p>
  987.      * Transparent pixels are drawn in the specified background color. 
  988.      * This operation is equivalent to filling a rectangle of the
  989.      * width and height of the specified image with the given color and then
  990.      * drawing the image on top of it, but possibly more efficient.
  991.      * <p>
  992.      * This method returns immediately in all cases, even if the
  993.      * image area to be drawn has not yet been scaled, dithered, and converted
  994.      * for the current output device.
  995.      * If the current output representation is not yet complete then
  996.      * <code>drawImage</code> returns <code>false</code>. As more of
  997.      * the image becomes available, the process that draws the image notifies 
  998.      * the specified image observer.
  999.      * <p>
  1000.      * This method always uses the unscaled version of the image
  1001.      * to render the scaled rectangle and performs the required
  1002.      * scaling on the fly. It does not use a cached, scaled version
  1003.      * of the image for this operation. Scaling of the image from source
  1004.      * to destination is performed such that the first coordinate
  1005.      * of the source rectangle is mapped to the first coordinate of
  1006.      * the destination rectangle, and the second source coordinate is
  1007.      * mapped to the second destination coordinate. The subimage is
  1008.      * scaled and flipped as needed to preserve those mappings.
  1009.      * @param       img the specified image to be drawn
  1010.      * @param       dx1 the <i>x</i> coordinate of the first corner of the
  1011.      *                    destination rectangle.
  1012.      * @param       dy1 the <i>y</i> coordinate of the first corner of the
  1013.      *                    destination rectangle.
  1014.      * @param       dx2 the <i>x</i> coordinate of the second corner of the
  1015.      *                    destination rectangle.
  1016.      * @param       dy2 the <i>y</i> coordinate of the second corner of the
  1017.      *                    destination rectangle.
  1018.      * @param       sx1 the <i>x</i> coordinate of the first corner of the
  1019.      *                    source rectangle.
  1020.      * @param       sy1 the <i>y</i> coordinate of the first corner of the
  1021.      *                    source rectangle.
  1022.      * @param       sx2 the <i>x</i> coordinate of the second corner of the
  1023.      *                    source rectangle.
  1024.      * @param       sy2 the <i>y</i> coordinate of the second corner of the
  1025.      *                    source rectangle.
  1026.      * @param       bgcolor the background color to paint under the
  1027.      *                    non-opaque portions of the image.
  1028.      * @param       observer object to be notified as more of the image is
  1029.      *                    scaled and converted.
  1030.      * @see         java.awt.Image
  1031.      * @see         java.awt.image.ImageObserver
  1032.      * @see         java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int)
  1033.      * @since       JDK1.1
  1034.      */
  1035.     public abstract boolean drawImage(Image img,
  1036.                       int dx1, int dy1, int dx2, int dy2,
  1037.                       int sx1, int sy1, int sx2, int sy2,
  1038.                       Color bgcolor,
  1039.                       ImageObserver observer);
  1040.  
  1041.     /**
  1042.      * Disposes of this graphics context and releases 
  1043.      * any system resources that it is using. 
  1044.      * A <code>Graphics</code> object cannot be used after 
  1045.      * <code>dispose</code>has been called.
  1046.      * <p>
  1047.      * When a Java program runs, a large number of <code>Graphics</code>
  1048.      * objects can be created within a short time frame.
  1049.      * Although the finalization process of the garbage collector 
  1050.      * also disposes of the same system resources, it is preferable 
  1051.      * to manually free the associated resources by calling this
  1052.      * method rather than to rely on a finalization process which 
  1053.      * may not run to completion for a long period of time.
  1054.      * <p>
  1055.      * Graphics objects which are provided as arguments to the 
  1056.      * <code>paint</code> and <code>update</code> methods 
  1057.      * of components are automatically released by the system when 
  1058.      * those methods return. For efficiency, programmers should
  1059.      * call <code>dispose</code> when finished using
  1060.      * a <code>Graphics</code> object only if it was created 
  1061.      * directly from a component or another <code>Graphics</code> object.
  1062.      * @see         java.awt.Graphics#finalize
  1063.      * @see         java.awt.Component#paint
  1064.      * @see         java.awt.Component#update
  1065.      * @see         java.awt.Component#getGraphics
  1066.      * @see         java.awt.Graphics#create
  1067.      */
  1068.     public abstract void dispose();
  1069.  
  1070.     /**
  1071.      * Disposes of this graphics context once it is no longer referenced.
  1072.      * @see #dispose
  1073.      */
  1074.     public void finalize() {
  1075.     dispose();
  1076.     }
  1077.  
  1078.     /**
  1079.      * Returns a <code>String</code> object representing this 
  1080.      *                        <code>Graphics</code> object's value.
  1081.      * @return       a string representation of this graphics context.
  1082.      */
  1083.     public String toString() {    
  1084.     return getClass().getName() + "[font=" + getFont() + ",color=" + getColor() + "]";
  1085.     }
  1086.  
  1087.     /**
  1088.      * @deprecated As of JDK version 1.1,
  1089.      * replaced by <code>getClipBounds()</code>.
  1090.      */
  1091.     public Rectangle getClipRect() {
  1092.     return getClipBounds();
  1093.     }
  1094.  
  1095.     /**
  1096.      * Returns true if the specified rectangular area intersects 
  1097.      * the bounding rectangle of the current clipping area.
  1098.      * The coordinates in the rectangle are relative to the coordinate
  1099.      * system origin of this graphics context.
  1100.      *
  1101.      * @param x the x coordinate of the rectangle to test against the clip
  1102.      * @param y the y coordinate of the rectangle to test against the clip
  1103.      * @param width the width of the rectangle to test against the clip
  1104.      * @param height the height of the rectangle to test against the clip
  1105.      */
  1106.     public boolean hitClip(int x, int y, int width, int height) {
  1107.         // FIXME: 1.2 beta3 placeholder, replace for beta4
  1108.         return new Rectangle(x,y,width,height).intersects(getClipBounds());
  1109.     }
  1110.  
  1111.     /**
  1112.      * Returns the bounding rectangle of the current clipping area.
  1113.      * The coordinates in the rectangle are relative to the coordinate
  1114.      * system origin of this graphics context.  This method differs
  1115.      * getClipBounds() in that an existing rectangle is used instead
  1116.      * of allocating a new one.
  1117.      * @param  r    the rectangle where the current clipping area is
  1118.      *              copied to.  Any current values in this rectangle are
  1119.      *              overwritten.
  1120.      * @return      the bounding rectangle of the current clipping area.
  1121.      */
  1122.     public Rectangle getClipBounds(Rectangle r) {
  1123.         // FIXME: 1.2 beta3 placeholder, replace for beta4
  1124.         Rectangle clipRect = getClipBounds();
  1125.         r.x = clipRect.x;
  1126.         r.y = clipRect.y;
  1127.         r.width = clipRect.width;
  1128.         r.height = clipRect.height;
  1129.         return r;
  1130.     }
  1131. }
  1132.